Ext.define('PJ.view.messagemanagement.Frame', {
    extend: 'Ext.container.Container',
    layout: 'border',
    // 必须增加这段，强制提前加载类，这样才可以使用简写
    requires: [],
    items: [{
        region: 'center',
        xtype: 'tabpanel',
        listeners: {
            beforerender: function(){
            
                // 获取权限
                var cp = Ext.create('Ext.state.CookieProvider');
                Ext.state.Manager.setProvider(cp);
                var Obj = cp.get("permissions");
                
                var waitingPermissions = Obj["PJ.view.messagemanagement.SendMessageList"];
                var flag1 = true;
                if (waitingPermissions) {
                    for (var i = 0; i < waitingPermissions.length; i++) {
                        if (waitingPermissions[i] == "List") {
                            flag1 = false;
                            break;
                        }
                    }
                }
                
                var shippedPermissions = Obj["PJ.view.messagemanagement.ReceiveMessagesList"];
                var flag2 = true;
                if (shippedPermissions) {
                    for (var i = 0; i < shippedPermissions.length; i++) {
                        if (shippedPermissions[i] == "List") {
                            flag2 = false;
                            break;
                        }
                    }
                }
                if (flag2) {
                    var tab2 = this.add(Ext.create('PJ.view.messagemanagement.ReceiveMessagesList', {
                        title: "接收通知"
                    }));
                }
                if (flag1) {
                    var tab1 = this.add(Ext.create('PJ.view.messagemanagement.SendMessageList', {
                        title: "发送通知"
                    }));
                }
                
                
                this.setActiveTab(0);
            },
            tabchange: function(tabPanel, newCard, oldCard){
                if (newCard.searchDepID != null) {
                    if (newCard.flag) {
                        newCard.store.load();
                        newCard.flag = false;
                    }
                }
            }
        }
    }],
    listeners: {
        beforerender: function(){
            //Ext.getCmp("loadingMask").show();
        }
    }
});
